package com.isunland.managesystem.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseListAdapter;
import com.isunland.managesystem.entity.OrderCountQuery;
import com.isunland.managesystem.entity.OrderSaleCollectOriginal.OrderSaleCollectContent;
import com.isunland.managesystem.utils.LogUtil;
import java.util.List;

public class OrderCountListAdapter extends BaseListAdapter<OrderSaleCollectContent> {
  private String statisticType;
  private OrderCountQuery countQuery = new OrderCountQuery();//统计字段类对象

  public OrderCountListAdapter(Context context, List<OrderSaleCollectContent> objects) {
    super(context, objects);
  }

  public OrderCountListAdapter(Context context, List<OrderSaleCollectContent> objects,
      String statisticType) {
    super(context, objects);
    this.statisticType = statisticType;
  }

  public OrderCountListAdapter(Context context, List<OrderSaleCollectContent> objects,
      String statisticType, OrderCountQuery countQuery) {
    super(context, objects);
    this.statisticType = statisticType;
    this.countQuery = countQuery;
  }

  @Override
  public void bindData(int position, BaseListAdapter.ViewHolder vh, OrderSaleCollectContent item) {
    //初始化数据,选择的出入库类型不同，显示字段也不同

    //出库：业务员 ,客户/单位 ,物料名称 ,所在仓库,申请出库数量,实际出库数量   01
    //出库：业务员 ,客户/单位 ,物料名称 ,所在仓库,申请入库数量 ，实际入库数量   02
    LogUtil.i("countQuery===" + countQuery.getAppMan());

    //出库
    if ("01".equals(statisticType)) {
      vh.mTitleOneTv.setText(R.string.salesman_colon);
      vh.mContentOneTv.setText(item.getAppManName());

      vh.mTitleTwoTv.setText(R.string.customer_unit_colon);
      vh.mContentTwoTv.setText(item.getCustomerName());

      vh.mTitleThreeTv.setText(R.string.materiel_name);
      vh.mContentThreeTv.setText(item.getMaterialName());

      vh.mTitleFourTv.setText(R.string.storage);
      vh.mContentFourTv.setText(item.getStorageName());//所在仓库

      vh.mTitleFiveTv.setText(R.string.apply_outNumber);
      vh.mContentFiveTv.setText(item.getInoroutNumber());

      vh.mTitleSixTv.setText(R.string.real_outNumber);
      vh.mContentSixTv.setText(item.getActualInoroutNumber());
    }
    //入库
    else if ("02".equals(statisticType)) {
      vh.mTitleOneTv.setText(R.string.salesman_colon);
      vh.mContentOneTv.setText(item.getAppManName());

      vh.mTitleTwoTv.setText(R.string.supplier_unit_colon);
      vh.mContentTwoTv.setText(item.getCustomerName());

      vh.mTitleThreeTv.setText(R.string.materiel_name);
      vh.mContentThreeTv.setText(item.getMaterialName());

      vh.mTitleFourTv.setText(R.string.storage);
      vh.mContentFourTv.setText(item.getStorageName());//所在仓库

      vh.mTitleFiveTv.setText(R.string.apply_inNumber);
      vh.mContentFiveTv.setText(item.getInoroutNumber());

      vh.mTitleSixTv.setText(R.string.real_inNumber);
      vh.mContentSixTv.setText(item.getActualInoroutNumber());
    }

    if (TextUtils.isEmpty(countQuery.getAppMan())) {
      vh.mHolderOneVg.setVisibility(View.GONE);
    }
    if (TextUtils.isEmpty(countQuery.getCustomer())) {
      vh.mHolderTwoVg.setVisibility(View.GONE);
    }
    if (TextUtils.isEmpty(countQuery.getMaterial())) {
      vh.mHolderThreeVg.setVisibility(View.GONE);
    }
    if (TextUtils.isEmpty(countQuery.getStorage())) {
      vh.mHolderFourVg.setVisibility(View.GONE);
    }
  }
}
